//
// AWS Manager - A free AWS console application demonstrating advanced concepts
// Copyright (C) 2008-2010 Sean O'Dell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.awsmanager.common;

import com.xerox.amazonws.ec2.InstanceType;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;

/**
 *
 * @author Sean ODell
 */
public class EC2Instance {

    private String instanceRegion;
    private String instanceId;
    private String imageId;
    private String privateDnsName;
    private String dnsName;
    private String stateName;
    private String reason;
    private String keyName;
    private String instanceType;
    private String launchTime;
    private int durationHours;
    private String availabilityZone;
    private String kernelId;
    private String ramdiskId;

    /* meta data */
    private String instname;
    private String instdesc;
    private String instownernamelast;
    private String instownernamefirst;
    private String instownerdept;

    /** Creates a new instance of EC2Instance */
    public EC2Instance() {
    }

    public String getInstanceRegion() {
        return instanceRegion;
    }

    public void setInstanceRegion(String instanceRegion) {
        this.instanceRegion = instanceRegion;
    }

    public String getimageId() {
        return imageId;
    }

    public void setimageId(String imageId) {
        this.imageId = imageId;
    }

    public String getinstanceId() {
        return instanceId;
    }

    public void setinstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    public String getprivateDnsName() {
        return privateDnsName;
    }

    public void setprivateDnsName(String privateDnsName) {
        this.privateDnsName = privateDnsName;
    }

    public String getdnsName() {
        return dnsName;
    }

    public void setdnsName(String dnsName) {
        this.dnsName = dnsName;
    }

    public String getstateName() {
        return stateName;
    }

    public void setstateName(String stateName) {
        this.stateName = stateName;
    }

    public String getinstanceType() {
        return instanceType;
    }

    public void setinstanceType(InstanceType instanceType) {
        this.instanceType = instanceType.getTypeId();
    }

    public String getavailabilityZone() {
        return availabilityZone;
    }

    public void setavailabilityZone(String availabilityZone) {
        this.availabilityZone = availabilityZone;
    }

    public String getlaunchTime() {
        return launchTime;
    }

    public void setlaunchTime(Calendar launchTime) {
        Date launchDate = launchTime.getTime();
        Date currentDate = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");

        double diff = currentDate.getTime() - launchDate.getTime();

        this.launchTime = dateFormat.format(launchDate);
        this.durationHours = (int) Math.ceil(diff / (1000 * 60 * 60));
    }

    public int getdurationHours() {
        return durationHours;
    }

    public String getinstname() {
        return instname;
    }

    public void setinstname(String instname) {
        this.instname = instname;
    }

    public String getinstdesc() {
        return instdesc;
    }

    public void setinstdesc(String instdesc) {
        this.instdesc = instdesc;
    }

    public String getinstownernamelast() {
        return instownernamelast;
    }

    public void setinstownernamelast(String instownernamelast) {
        this.instownernamelast = instownernamelast;
    }

    public String getinstownernamefirst() {
        return instownernamefirst;
    }

    public void setinstownernamefirst(String instownernamefirst) {
        this.instownernamefirst = instownernamefirst;
    }

    public String getinstownerdept() {
        return instownerdept;
    }

    public void setinstownerdept(String instownerdept) {
        this.instownerdept = instownerdept;
    }

    public String getKeyName() {
        return keyName;
    }

    public void setKeyName(String keyName) {
        this.keyName = keyName;
    }

}
